package lancooPaperContent;

import android.content.Context;
import android.text.Editable;
import android.text.Html;
import android.text.TextWatcher;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.RotateAnimation;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.example.lancooznbk.R;
import com.example.lancooznbk.presenter.PaperDef;

import org.apache.commons.lang3.StringEscapeUtils;

import lancooControl.CustomEditText;

import static android.view.View.GONE;
import static testPaperCTCS.GuessTestingPaperActivity.InforGuessTesting;
import static testPaperFavoritesPage.FavoritesPagePaperActivity.InforFavoritesPage;
import static testPaperJBFX.BasicReviewPaperActivity.InforBasicReview;
import static testPaperNDFX.DifficultReviewPaperActivity.InforDifficultReview;
import static testPaperWrong.WrongQuesPaperActivity.InforWrongQues;
import static testPaperWrongHistory.HistoryWrongQuesPaperActivity.InforHistoryWrongQues;

/**
 * Created by Administrator on 2017/10/12/012.
 */

public class ContentYyzAdapter extends WrapBaseAdapter {

    private LayoutInflater mInflater;
    private Context mContext;
    //当前试题数量
    private int SumItem;
    //当前试题在当前试卷的ID
    private int PaperID;
    private int ModelFrom;//试卷来源

    private int tvBlack;
    private int tvBlue;
    private int tvWhite;
    private int tvGreen;
    private int tvRed;
    private int tvGray;

    private ViewHolder holder = null;
    private class ViewHolder{
        TextView TvTypeName;//题目类型
        Button BtnIntoStudy;//进入辅导
        WebView WvTheme;//大题文本题干区
        LinearLayout LayoutEdt;//作文输入区所在布局
        CustomEditText EdtAnswer;//作文输入区
        LinearLayout LayoutAnalysis;//答案回看解析区
        TextView TvStuAnswer;//学生答案
        TextView TvAnswer;//参考答案
        TextView TvScore;//得分
        TextView TvAnalysis;//解析
        TextView TvStuAssess;//自评
        LinearLayout LayoutScore;//回看得分

        LinearLayout LayoutClassicExample;//经典案例显示区
        LinearLayout LayoutClassicMenu;//参考答案及解析按钮
        ImageView IvClassic;//参考答案及解析箭头
        LinearLayout LayoutClassic;//参考答案及解析显示区
        TextView TvClassicAnswer;//参考答案
        TextView TvClassicAnalysis;//解析

        private ViewHolder(View convertView) {

            TvTypeName = (TextView) convertView.findViewById(R.id.tv_type_name);
            BtnIntoStudy = (Button) convertView.findViewById(R.id.btn_into_study);
            WvTheme = (WebView) convertView.findViewById(R.id.wv_theme);
            LayoutEdt = (LinearLayout) convertView.findViewById(R.id.layout_edt);
            EdtAnswer = (CustomEditText) convertView.findViewById(R.id.edt_answer);
            LayoutAnalysis = (LinearLayout) convertView.findViewById(R.id.layout_analysis);
            TvStuAnswer = (TextView) convertView.findViewById(R.id.tv_stu_answer);
            TvAnswer = (TextView) convertView.findViewById(R.id.tv_answer);
            TvScore = (TextView) convertView.findViewById(R.id.tv_score);
            TvAnalysis = (TextView) convertView.findViewById(R.id.tv_analysis);
            TvStuAssess = (TextView) convertView.findViewById(R.id.tv_stu_assess);
            LayoutScore = (LinearLayout) convertView.findViewById(R.id.layout_score);

            LayoutClassicExample = (LinearLayout) convertView.findViewById(R.id.layout_classic_example);
            LayoutClassicMenu = (LinearLayout) convertView.findViewById(R.id.layout_classic_menu);
            LayoutClassicMenu.setOnClickListener(new clickListener());
            IvClassic = (ImageView) convertView.findViewById(R.id.iv_classic);
            LayoutClassic = (LinearLayout) convertView.findViewById(R.id.layout_classic);
            TvClassicAnswer = (TextView) convertView.findViewById(R.id.tv_classic_answer);
            TvClassicAnalysis = (TextView) convertView.findViewById(R.id.tv_classic_analysis);
        }
    }

    /*
   * 获取小题选项信息
   * */
    private String theme;//大题题干
    private String quesImage = "";//作文大题题干图片信息
    private int state;//试卷的作答状态
    private int isAssess;//本题是否可自评
    private String stuAssess;//自评/机评结果
    private String stuAnswer;//用户答案
    private String answer;//正确答案
    private double score;//试题总分值
    private String analysis;//答案解析
    private Double correctRate;//该题准确率
    private String typeName;

    public ContentYyzAdapter(Context context, int sumItem, int paperID, int modelFrom) {
        mInflater = LayoutInflater.from(context);
        this.mContext = context;
        this.SumItem = sumItem;
        this.PaperID = paperID;
        this.ModelFrom = modelFrom;
    }

    @Override
    public int getCount() {
        return SumItem;
    }

    @Override
    public Object getItem(int position) {
        return position;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {

        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.adapter_content_yyz_item, null);
            holder = new ViewHolder(convertView);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        /*
        * 获取作文题用户相关信息
        * */
        getInfor();

        /*
        * 显示题干信息
        * */
        showInfor();

        /*
        * 用户输入框作答
        * */
        edtStuAnswer();

        /*
        * 显示用户回看解析相关信息
        */
        showAnalysis();

        return convertView;
    }


    /*
    * 获取作文题用户相关信息
    * */
    private void  getInfor(){

        tvBlack = mContext.getResources().getColor(R.color.black);
        tvBlue = mContext.getResources().getColor(R.color.blue);
        tvWhite = mContext.getResources().getColor(R.color.white);
        tvGreen = mContext.getResources().getColor(R.color.green);
        tvRed = mContext.getResources().getColor(R.color.red);
        tvGray = mContext.getResources().getColor(R.color.gray);

        if(ModelFrom== PaperDef.FROM_BASE_REVIEW) {
            theme = InforBasicReview.getPaperContent().get(PaperID).getTheme();
            stuAnswer = InforBasicReview.getPaperContent().get(PaperID).getQueList().get(0).getStuAnswer();
            state = InforBasicReview.getState();
            answer = InforBasicReview.getPaperContent().get(PaperID).getQueList().get(0).getAnswer();
            score = InforBasicReview.getPaperContent().get(PaperID).getScore();
            analysis = InforBasicReview.getPaperContent().get(PaperID).getQueList().get(0).getAnalysis();
            stuAssess = InforBasicReview.getPaperContent().get(PaperID).getQueList().get(0).getStuAssess();
            correctRate = InforBasicReview.getPaperContent().get(PaperID).getCorrectRate();
            typeName = InforBasicReview.getPaperContent().get(PaperID).getTypeName();

            InforBasicReview.getPaperContent().get(PaperID).setStuAnswerOldAll(stuAnswer);
            InforBasicReview.getPaperContent().get(PaperID).setStuAssessOldAll(stuAssess);
            InforBasicReview.getPaperContent().get(PaperID).setStuAnswerNewAll(stuAnswer);
            InforBasicReview.getPaperContent().get(PaperID).setStuAssessNewAll(stuAssess);

        }else if(ModelFrom==PaperDef.FROM_DIFFERENT_REVIEW){
            theme = InforDifficultReview.getTheme();
            stuAnswer = InforDifficultReview.getQueList().get(0).getStuAnswer();
            state = InforDifficultReview.getState();
            answer = InforDifficultReview.getQueList().get(0).getAnswer();
            score = InforDifficultReview.getScore();
            analysis = InforDifficultReview.getQueList().get(0).getAnalysis();
            stuAssess = InforDifficultReview.getQueList().get(0).getStuAssess();

            InforDifficultReview.setStuAnswerOldAll(stuAnswer);
            InforDifficultReview.setStuAssessOldAll(stuAssess);
            InforDifficultReview.setStuAnswerNewAll(stuAnswer);
            InforDifficultReview.setStuAssessNewAll(stuAssess);
        }else if(ModelFrom==PaperDef.FROM_GUESS_REVIEW){
            theme = InforGuessTesting.getPaperContent().get(PaperID).getTheme();
            stuAnswer = InforGuessTesting.getPaperContent().get(PaperID).getQueList().get(0).getStuAnswer();
            state = InforGuessTesting.getState();
            answer = InforGuessTesting.getPaperContent().get(PaperID).getQueList().get(0).getAnswer();
            score = InforGuessTesting.getPaperContent().get(PaperID).getScore();
            analysis = InforGuessTesting.getPaperContent().get(PaperID).getQueList().get(0).getAnalysis();
            stuAssess = InforGuessTesting.getPaperContent().get(PaperID).getQueList().get(0).getStuAssess();

            InforGuessTesting.getPaperContent().get(PaperID).setStuAnswerOldAll(stuAnswer);
            InforGuessTesting.getPaperContent().get(PaperID).setStuAssessOldAll(stuAssess);
            InforGuessTesting.getPaperContent().get(PaperID).setStuAnswerNewAll(stuAnswer);
            InforGuessTesting.getPaperContent().get(PaperID).setStuAssessNewAll(stuAssess);
        }else if(ModelFrom==PaperDef.FROM_BASE_REVIEW_WRONG||ModelFrom==PaperDef.FROM_DIFFERENT_REVIEW_WRONG){

            theme = InforWrongQues.get(PaperID).getTheme();
            stuAnswer = InforWrongQues.get(PaperID).getQueList().get(0).getStuAnswer();
            state = InforWrongQues.get(PaperID).getState();
            answer = InforWrongQues.get(PaperID).getQueList().get(0).getAnswer();
            score = InforWrongQues.get(PaperID).getScore();
            analysis = InforWrongQues.get(PaperID).getQueList().get(0).getAnalysis();
            stuAssess = InforWrongQues.get(PaperID).getQueList().get(0).getStuAssess();

            InforWrongQues.get(PaperID).setStuAnswerOldAll(stuAnswer);
            InforWrongQues.get(PaperID).setStuAssessOldAll(stuAssess);
            InforWrongQues.get(PaperID).setStuAnswerNewAll(stuAnswer);
            InforWrongQues.get(PaperID).setStuAssessNewAll(stuAssess);

        }else if(ModelFrom==PaperDef.FROM_BASE_REVIEW_WRONG_History||ModelFrom==PaperDef.FROM_DIFFERENT_REVIEW_WRONG_History){
            theme = InforHistoryWrongQues.get(PaperID).getTheme();
            stuAnswer = InforHistoryWrongQues.get(PaperID).getQueList().get(0).getStuAnswer();
            state = InforHistoryWrongQues.get(PaperID).getState();
            answer = InforHistoryWrongQues.get(PaperID).getQueList().get(0).getAnswer();
            score = InforHistoryWrongQues.get(PaperID).getScore();
            analysis = InforHistoryWrongQues.get(PaperID).getQueList().get(0).getAnalysis();
            stuAssess = InforHistoryWrongQues.get(PaperID).getQueList().get(0).getStuAssess();

            InforHistoryWrongQues.get(PaperID).setStuAnswerOldAll(stuAnswer);
            InforHistoryWrongQues.get(PaperID).setStuAssessOldAll(stuAssess);
            InforHistoryWrongQues.get(PaperID).setStuAnswerNewAll(stuAnswer);
            InforHistoryWrongQues.get(PaperID).setStuAssessNewAll(stuAssess);
        }else if(ModelFrom==PaperDef.FROM_FAVOURITE_REVIEW){
            theme = InforFavoritesPage.getTheme();
            stuAnswer = InforFavoritesPage.getQueList().get(0).getStuAnswer();
            state = InforFavoritesPage.getState();
            answer = InforFavoritesPage.getQueList().get(0).getAnswer();
            score = InforFavoritesPage.getScore();
            analysis = InforFavoritesPage.getQueList().get(0).getAnalysis();
            stuAssess = InforFavoritesPage.getQueList().get(0).getStuAssess();
        }
    }

    /*
    * 显示界面信息
    * */
    private void showInfor(){

        if(typeName.equals("作文")){
            holder.TvTypeName.setText("题目类型-作文");
        }else if (typeName.equals("看图写句子")){
            holder.TvTypeName.setText("题目类型-看图写句子");
        }else if (typeName.equals("中译英")){
            holder.TvTypeName.setText("题目类型-中译英");
        }else if (typeName.equals("英译中")){
            holder.TvTypeName.setText("题目类型-英译中");
        }

        getTheme();
        if(state!=2){

            if (PaperID == 0 && ModelFrom == PaperDef.FROM_BASE_REVIEW_WRONG||
                    PaperID == 0 && ModelFrom == PaperDef.FROM_DIFFERENT_REVIEW_WRONG) {
                holder.LayoutEdt.setVisibility(View.GONE);
            }else{

                if(stuAnswer.equals("")){
                    holder.EdtAnswer.setHint("请在这里输入答案...");
                }else{
                    holder.EdtAnswer.setText(stuAnswer);
                }

            }
        }else{
            holder.LayoutEdt.setVisibility(View.GONE);
            if(correctRate>=0.7){
                holder.BtnIntoStudy.setVisibility(View.GONE);
            }else{
                holder.BtnIntoStudy.setVisibility(View.VISIBLE);
            }
        }
    }

    /*
   * 获取题目题干信息
   * */
//    Handler htmlHandlerTheme = new Handler();
//    private void showItemContent(){
//
//        theme = StringEscapeUtils.unescapeXml(theme);
//
//        new Thread(new Runnable()
//        {
//            @Override
//            public void run()
//            {
//                final Spanned tvTheme = Html.fromHtml(theme, Control.imgGetter,null);
//                htmlHandlerTheme.post(new Runnable()
//                {
//                    @Override
//                    public void run()
//                    {
//                        holder.TvTheme.setText(tvTheme);
//                    }
//                });
//            }
//        }).start();
//
//    }
    private void getTheme(){
        theme = StringEscapeUtils.unescapeXml(theme);
        holder.WvTheme.loadDataWithBaseURL("about:blank",theme,"text/html","utf-8",null);
    }


    /*
    * 用户作答
    * */
    private void edtStuAnswer(){

        if (state == 2 || (PaperID == 0 && ModelFrom == PaperDef.FROM_BASE_REVIEW_WRONG) ||
                (PaperID == 0 && ModelFrom == PaperDef.FROM_DIFFERENT_REVIEW_WRONG)) {
            holder.EdtAnswer.setFocusable(false);
            holder.EdtAnswer.setLongClickable(false);
            holder.LayoutEdt.setVisibility(View.GONE);
        }


        holder.EdtAnswer.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {

            }

            @Override
            public void afterTextChanged(Editable s) {
                setStuAnswer(s.toString());
            }
        });
    }

    /*
    * 显示试题解析回看信息
    * */
    private void showAnalysis(){

        if(ModelFrom==PaperDef.FROM_FAVOURITE_REVIEW||
                (PaperID==1&&(ModelFrom==PaperDef.FROM_BASE_REVIEW_WRONG||ModelFrom==PaperDef.FROM_DIFFERENT_REVIEW_WRONG))){

            holder.LayoutEdt.setVisibility(View.GONE);
            holder.LayoutAnalysis.setVisibility(View.GONE);
            holder.LayoutClassicExample.setVisibility(View.VISIBLE);

            holder.LayoutClassic.setVisibility(View.GONE);
            answer = StringEscapeUtils.unescapeXml(answer);
            holder.TvClassicAnswer.setText(Html.fromHtml(answer));;
            if(analysis.equals("")){
                holder.TvClassicAnalysis.setText("暂无解析");
            }else {
                analysis = StringEscapeUtils.unescapeXml(analysis);
                holder.TvClassicAnalysis.setText(Html.fromHtml(analysis));
            }
        }else {


            if (state == 2 || (PaperID == 0 && ModelFrom == PaperDef.FROM_BASE_REVIEW_WRONG) || (PaperID == 0 && ModelFrom == PaperDef.FROM_DIFFERENT_REVIEW_WRONG)) {
                holder.LayoutAnalysis.setVisibility(View.VISIBLE);

                holder.LayoutEdt.setVisibility(View.GONE);
                if (ModelFrom == PaperDef.FROM_BASE_REVIEW || ModelFrom == PaperDef.FROM_GUESS_REVIEW) {
                    holder.LayoutScore.setVisibility(View.VISIBLE);
                } else {
                    holder.LayoutScore.setVisibility(View.GONE);
                }

                if(stuAnswer.equals("")){
                    stuAnswer = "已在纸面完成作答";
                    holder.TvStuAnswer.setTextColor(tvGreen);
                }else{
                    if(stuAnswer.equals(answer)){
                        holder.TvStuAnswer.setTextColor(tvGreen);
                    }else{
                        holder.TvStuAnswer.setTextColor(tvRed);
                    }
                }
                holder.TvStuAnswer.setText(stuAnswer);


                if (answer.equals("")) {
                    answer = "暂无参考答案";
                }
                answer = StringEscapeUtils.unescapeXml(answer);
                holder.TvAnswer.setText(Html.fromHtml(answer));

                double stuScore = 0;
                if (!stuAssess.equals("")) {
                    if (!stuAssess.equals("较差")) {
                        if (stuAssess.equals("优秀") || stuAssess.equals("一般")) {
                            stuScore = score * 1.0;
                        } else {
                            stuScore = Double.valueOf(stuAssess);
                        }
                    } else {
                        stuScore = score * 0;
                    }
                } else {
                    if (stuAnswer.equals(answer)) {
                        stuScore = score * 1.0;
                    } else {
                        stuScore = score * 0;
                    }
                }
                holder.TvScore.setText(String.valueOf(stuScore) + "分");

                if (analysis.equals("")) {
                    analysis = "暂无解析";
                }
                analysis = StringEscapeUtils.unescapeXml(analysis);
                holder.TvAnalysis.setText(Html.fromHtml(analysis));

                if (stuAssess.equals("")) {
                    holder.TvStuAssess.setText("未自评");
                } else {
                    if (ModelFrom == PaperDef.FROM_GUESS_REVIEW) {
                        holder.TvStuAssess.setText(stuAssess + "分");
                    } else {
                        holder.TvStuAssess.setText(stuAssess);
                    }
                }

            } else {
                holder.LayoutEdt.setVisibility(View.VISIBLE);
                holder.LayoutAnalysis.setVisibility(View.GONE);
            }
            holder.LayoutClassicExample.setVisibility(View.GONE);
        }
    }

    /*
  * 写入作答信息
  * */
    private void setStuAnswer(String strStuAnswer){
        if(ModelFrom==PaperDef.FROM_BASE_REVIEW){
            InforBasicReview.getPaperContent().get(PaperID).getQueList().get(0).setStuAnswer(strStuAnswer);

            String thisStuAnswer = InforBasicReview.getPaperContent().get(PaperID).getQueList().get(0).getStuAnswer();
            String thisAnswer = InforBasicReview.getPaperContent().get(PaperID).getQueList().get(0).getAnswer();
            String thisStuAssess = InforBasicReview.getPaperContent().get(PaperID).getQueList().get(0).getStuAssess();

            InforBasicReview.getPaperContent().get(PaperID).setStuAnswerNewAll(thisStuAnswer);
            Log.e("====StuAnswerNewAll====","=-=-="+state);

            if(!thisStuAssess.equals("")){
                if (thisStuAssess.equals("优秀")||thisStuAssess.equals("一般")) {
                    correctRate = 1.0;
                }else{
                    correctRate = 0.0;
                }
            }else{
                if(thisStuAnswer.equals(thisAnswer)){
                    correctRate = 1.0;
                }else{
                    correctRate = 0.0;
                }
            }
            InforBasicReview.getPaperContent().get(PaperID).setCorrectRate(correctRate);

            int quesAnsweredItemCount = 0;
            if(thisStuAssess.equals("")&&thisStuAnswer.equals("")){
                quesAnsweredItemCount = 0;
            }else{
                quesAnsweredItemCount = 1;
            }
            InforBasicReview.getPaperContent().get(PaperID).setAnsweredItemCount(quesAnsweredItemCount);

        }else if(ModelFrom==PaperDef.FROM_DIFFERENT_REVIEW){

            InforDifficultReview.getQueList().get(0).setStuAnswer(strStuAnswer);
            String thisStuAnswer = InforDifficultReview.getQueList().get(0).getStuAnswer();
            String thisAnswer = InforDifficultReview.getQueList().get(0).getAnswer();
            String thisStuAssess = InforDifficultReview.getQueList().get(0).getStuAssess();

            InforDifficultReview.setStuAnswerNewAll(thisStuAnswer);
            Log.e("====StuAnswerNewAll====","=-=-="+state);

            double correctRate= 0.0;
            if(!thisStuAssess.equals("")){
                if (thisStuAssess.equals("优秀")||thisStuAssess.equals("一般")) {
                    correctRate = 1.0;
                }else{
                    correctRate = 0.0;
                }
            }else{
                if(thisStuAnswer.equals(thisAnswer)){
                    correctRate = 1.0;
                }else{
                    correctRate = 0.0;
                }
            }
            InforDifficultReview.setCorrectRate(correctRate);

            int quesAnsweredItemCount = 0;
            if(thisStuAssess.equals("")&&thisStuAnswer.equals("")){
                quesAnsweredItemCount = 0;
            }else{
                quesAnsweredItemCount = 1;
            }
            InforDifficultReview.setAnsweredItemCount(quesAnsweredItemCount);

        }else if(ModelFrom==PaperDef.FROM_GUESS_REVIEW){
            InforGuessTesting.getPaperContent().get(PaperID).getQueList().get(0).setStuAnswer(strStuAnswer);

            String thisStuAnswer = InforGuessTesting.getPaperContent().get(PaperID).getQueList().get(0).getStuAnswer();
            String thisAnswer = InforGuessTesting.getPaperContent().get(PaperID).getQueList().get(0).getAnswer();
            String thisStuAssess = InforGuessTesting.getPaperContent().get(PaperID).getQueList().get(0).getStuAssess();

            InforGuessTesting.getPaperContent().get(PaperID).setStuAnswerNewAll(thisStuAnswer);
            Log.e("====StuAnswerNewAll====","=-=-="+state);

            double correctRate= 0.0;
            if(!thisStuAssess.equals("")){
                if (thisStuAssess.equals("优秀")||thisStuAssess.equals("一般")) {
                    correctRate = 1.0;
                }else{
                    correctRate = 0.0;
                }
            }else{
                if(thisStuAnswer.equals(thisAnswer)){
                    correctRate = 1.0;
                }else{
                    correctRate = 0.0;
                }
            }
            InforGuessTesting.getPaperContent().get(PaperID).setCorrectRate(correctRate);

            int quesAnsweredItemCount = 0;
            if(thisStuAssess.equals("")&&thisStuAnswer.equals("")){
                quesAnsweredItemCount = 0;
            }else{
                quesAnsweredItemCount = 1;
            }
            InforGuessTesting.getPaperContent().get(PaperID).setAnsweredItemCount(quesAnsweredItemCount);
        }else if(ModelFrom==PaperDef.FROM_BASE_REVIEW_WRONG||ModelFrom==PaperDef.FROM_DIFFERENT_REVIEW_WRONG){

            InforWrongQues.get(PaperID).getQueList().get(0).setStuAnswer(strStuAnswer);

            String thisStuAnswer = InforWrongQues.get(PaperID).getQueList().get(0).getStuAnswer();
            String thisAnswer = InforWrongQues.get(PaperID).getQueList().get(0).getAnswer();
            String thisStuAssess = InforWrongQues.get(PaperID).getQueList().get(0).getStuAssess();

            InforWrongQues.get(PaperID).setStuAnswerNewAll(thisStuAnswer);
            Log.e("====StuAnswerNewAll====","=-=-="+state);

            double correctRate= 0.0;
            if(!thisStuAssess.equals("")){
                if (thisStuAssess.equals("优秀")||thisStuAssess.equals("一般")) {
                    correctRate = 1.0;
                }else{
                    correctRate = 0.0;
                }
            }else{
                if(thisStuAnswer.equals(thisAnswer)){
                    correctRate = 1.0;
                }else{
                    correctRate = 0.0;
                }
            }
            InforWrongQues.get(PaperID).setCorrectRate(correctRate);

            int quesAnsweredItemCount = 0;
            if(thisStuAssess.equals("")&&thisStuAnswer.equals("")){
                quesAnsweredItemCount = 0;
            }else{
                quesAnsweredItemCount = 1;
            }
            InforWrongQues.get(PaperID).setAnsweredItemCount(quesAnsweredItemCount);

        }
    }

    /**************************************************************************************************/
    /**************************************************************************************************/

    private class clickListener implements View.OnClickListener {
        public void onClick(View v) {
            if (holder.LayoutClassic.getVisibility() == GONE) {
                animationIvOpen();
                holder.LayoutClassic.setVisibility(View.VISIBLE);
            } else {
                animationIvClose();
                holder.LayoutClassic.setVisibility(View.GONE);
            }
        }
    }

    private void animationIvOpen() {
        RotateAnimation animation = new RotateAnimation(0, 180,
                Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
                0.5f);
        animation.setFillAfter(true);
        animation.setDuration(100);
        holder.IvClassic.startAnimation(animation);
    }

    private void animationIvClose() {
        RotateAnimation animation = new RotateAnimation(180, 0,
                Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
                0.5f);
        animation.setFillAfter(true);
        animation.setDuration(100);
        holder.IvClassic.startAnimation(animation);
    }
    /*********************************************************************************************************/
    /*********************************************************************************************************/

}